package com.jayhuang.user_center.exception;

import com.jayhuang.user_center.common.ErrorCode;
import lombok.Getter;

/**
 * 自定义业务异常
 */
@Getter
public class BusinessException extends RuntimeException{
    private static final long serialVersionUID = 1L;

    private final Integer code;

    private final String message;

    private final String description;

    public BusinessException(Integer code, String message, String description) {
        super(message);
        this.code = code;
        this.message = message;
        this.description = description;
    }

    public BusinessException(ErrorCode errorCode) {
        this(errorCode.getCode(), errorCode.getMessage(), "");
    }

    public BusinessException(ErrorCode errorCode, String description) {
        this(errorCode.getCode(), errorCode.getMessage(), description);
    }

    public BusinessException(Integer code, String message) {
        super(message);
        this.code = code;
        this.message = message;
        this.description = "";
    }
}
